<?php
namespace app\common\model\media;


use app\common\model\TimeModel;

class Account extends TimeModel
{
    protected $deleteTime = 'delete_time';

    /*
            * 遍历数据，查找parId为参数$parid指定的id
           */
    public function getAllNextId($id,$data=[]){
        $pids = app('app\common\model\common\Categories')->where(['parent_id'=>$id,'type'=>2])->coloumn('id')
           ;
        if(count($pids)>0){
            foreach($pids as $v){
                $data[] = $v;
                $data = $this->getAllNextId($v,$data); //注意写$data 返回给上级
            }
        }
        if(count($data)>0){
            return $data;
        }else{
            return [];
        }
    }
    /**
     * 获取对应的多态模型
     * @return \think\model\relation\MorphTo
     */
    public function relat_account()
    {
         return $this->morphTo();
    }

    //下所有的规格
    public function items()
    {
        return $this->hasMany('app\common\model\media\AccountItem','article_id','id');
    }
}